<template>
    <div>
        <el-dialog v-dialogDrag :visible.sync="addObj.isShow" :close-on-click-modal="false" title="新增${tableComment}" width="50%" @close="cancelDialog">
            <el-form ref="form" :model="form" :rules="rules" label-width="120px">
                <#list showProperty as propertyItem>
                <el-col :xs="24" :lg="12" :xl="8">
                    <el-form-item label="${propertyItem.columnComment}" prop="${propertyItem.property}">
                        <el-input v-model="form.${propertyItem.property}" clearable placeholder="${propertyItem.columnComment}"/>
                    </el-form-item>
                </el-col>
                </#list>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="cancelDialog">取 消</el-button>
                <el-button type="primary" @click="confirmForm">确 定</el-button>
            </div>
        </el-dialog>
    </div>

</template>

<script>
import { add${meta} } from '@/api/${apiUrl}'
export default {
    name: '',
    components: {
    },
    mixins: [
    ],
    props: {
        addObj: {
            type: Object,
            default: function() {
                return {}
            }
        }
    },
    data() {
        return {
            form: {
                <#list showProperty as propertyItem>
                ${propertyItem.property}:'',
                </#list>
            },
            rules: {

            }
        }
    },
    computed: {

    },
    watch: {

    },
    created() {
        this.getDrop()
    },
    mounted() {

    },
    methods: {
        // 获取下拉数据
        getDrop() {

        },
        // 提交表单
        confirmForm() {
            this.$refs['form'].validate((valid) => {
                if (valid) {
                    let params = {
                        ...this.form
                    }
                    add${meta}(params).then(res => {
                        if (res.code === 0) {
                            this.$alert(res.message, {
                                type: 'success',
                                confirmButtonText: '确定'
                            })
                            this.cancelDialog()
                        } else {
                            this.$alert(res.message, {
                                type: 'error',
                                confirmButtonText: '确定'
                            })
                        }
                    }).catch(err => {
                        console.log(err)
                    })
                }
            })
        },
        // 取消
        cancelDialog() {
            this.$emit('cancelAddDialog')
            this.$refs['form'].resetFields()
        }
    }
}
</script>

<style scoped lang="scss">

</style>